<template>
    <div class="RowPage1">
        <div v-if="organOverview">
            <card-item :data="cardData1" :flex="6" :min_width="636">
                <div class="overview">
                    <div class="left">
                        <h4>{{ organOverview.organName }}</h4>
                        <p>地址：{{ organOverview.organAddress }}</p>
                        <p>负责人：{{ organOverview.principal }} {{ organOverview.phone }}</p>
                        <el-button @click="dialogVisible = true" class="btn" type="primary">查看营业部分布</el-button>
                        <el-dialog
                            :visible.sync="dialogVisible"
                            width="1000px">
                            <img src="../../../assets/dashboard/map.png" alt="">
                        </el-dialog>
                    </div>
                    <div class="right">
                        <div>
                            <div>
                                <h5>分拣中心(个)</h5>
                                <div class="num">{{ organOverview.sortingCenterNumber }}</div>
                            </div>
                        </div>
                        <div>
                            <div>
                                <h5>营业部人数(个)</h5>
                                <div class="num">{{ organOverview.agencyNumber }}</div>
                            </div>
                        </div>
                        <div>
                            <div>
                                <h5>司机人数(个)</h5>
                                <div class="num">{{ organOverview.driverNumber }}</div>
                            </div>
                        </div>
                        <div>
                            <div>
                                <h5>快递员人数(个)</h5>
                                <div class="num">{{ organOverview.courierNumber }}</div>
                            </div>
                        </div>
                    </div>
                </div>
            </card-item>

            <card-item :data="cardData2" :flex="4" :min_width="448">
                <div class="data-today">
                    <div class="item">
                        <p>订单金额(元)</p>
                        <p id="orderAmountChanges"></p>
                        <p>
                            <span>较昨日 +{{ todayData.orderAmountChanges }}</span>
                            <img src="../../../assets/dashboard/arrow_top.png" alt="">
                        </p>
                    </div>
                    <div class="item">
                        <p>订单数量(笔)</p>
                        <p id="orderNumber"></p>
                        <p>
                            <span>较昨日 +{{ todayData.orderNumberChanges }}</span>
                            <img src="../../../assets/dashboard/arrow_top.png" alt="">
                        </p>
                    </div>
                    <div class="item">
                        <p>运输任务(次)</p>
                        <p id="transportTaskNumber"></p>
                        <p>
                            <span>较昨日 +{{ todayData.transportTaskNumberChanges }}</span>
                            <img src="../../../assets/dashboard/arrow_top.png" alt="">
                        </p>
                    </div>
                </div>
            </card-item>
        </div>

        <el-skeleton v-else animated style="width: 100%">
            <template slot="template">
                <el-skeleton-item
                    style="width: 100%; height: 240px; margin: 12px"
                />
            </template>
        </el-skeleton>
    </div>
</template>

<script>
import { numberDance } from '@/utils/numberDance'
import { mapState } from 'vuex'

export default {
    name: 'RowPage1',
    props: {
        organOverview: true,
        todayData: true,
        updateTime: true
    },
    watch: {
        updateTime (val) {
            this.cardData2.time = val
        },
        allMounted (val) {
            if (val) {
                numberDance('orderAmountChanges', this.todayData.orderAmount)
                numberDance('orderNumber', this.todayData.orderNumber, 1)
                numberDance('transportTaskNumber', this.todayData.transportTaskNumber, 1)
                this.$store.commit('setCardRender', true)
            }
        },
        allRender (val) {
            if (val) this.$store.commit('setCardMounted', false)
        }
    },
    data () {
        return {
            cardData1: {
                title: '机构概述'
            },
            cardData2: {
                title: '今日数据',
                time: ''
            },
            dialogVisible: false
        }
    },
    computed: {
        ...mapState(['allMounted', 'allRender'])
    }
}
</script>

<style scoped lang="scss">
::-webkit-scrollbar {
    display: none;
}

.RowPage1 {
    > div {
        width: 100%;
        display: flex;
        justify-content: space-between;
        overflow: auto;

        .overview {
            color: #303133;
            display: flex;

            > div {
                width: 50%;
                display: flex;
                flex-direction: column;
                justify-content: center;
            }

            .left {
                border-right: 1px solid #EBEEF5;

                h4 {
                    font-weight: normal;
                    margin-bottom: 8px;
                }

                p {
                    font-size: 14px;
                    color: #818693;
                    margin: 4px 0;
                }

                .btn {
                    width: 158px;
                    height: 40px;
                    font-size: 14px;
                    background: #FFEEEB;
                    border: 1px solid #F3917C;
                    color: #E15536;
                    margin-top: 18px;

                    &:hover {
                        color: white;
                        background-color: #FF6B4A;
                    }
                }

                ::v-deep .el-dialog {
                    .el-dialog__header {
                        padding: 0;

                        .el-dialog__headerbtn {
                            top: 32px;
                            right: 36px;

                            * {
                                font-size: 24px;
                                color: transparent;
                            }
                        }
                    }

                    .el-dialog__body {
                        display: flex;
                        padding: 0;

                        img {
                            width: 1000px;
                        }
                    }
                }
            }

            .right {
                flex-wrap: wrap;
                flex-direction: row;
                padding: 0 2vw;

                > div {
                    display: flex;
                    justify-content: center;
                    width: 50%;

                    > div {


                        h5 {
                            font-size: 14px;
                            margin-bottom: 10px;
                        }

                        .num {
                            font-size: 32px;
                            font-weight: bold;
                            color: #E15536;
                            cursor: pointer;
                            transition: all 0.1s;

                            &:hover {
                                color: #FF8266;
                            }
                        }
                    }
                }

                > div:nth-child(-n+2) {
                    margin-bottom: 16px;
                }
            }
        }

        .data-today {
            font-size: 14px;
            display: flex;
            flex: 1;

            .item {
                flex: 1;
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: space-between;
                padding: 18px 0;

                p:nth-child(1) {

                }

                p:nth-child(2) {
                    font-size: 36px;
                    font-weight: bold;
                }

                p:nth-child(3) {
                    display: flex;
                    align-items: center;
                    color: #818693;

                    img {
                        width: 15px;
                    }
                }
            }
        }
    }
}
</style>
